//
// Created by yangchao on 2022/5/12.
// 78. 子集: https://leetcode.cn/problems/subsets/
//
#include <vector>
using namespace std;

class Subsets{
public:
    vector<vector<int>> subsets(vector<int>& nums) {
        vector<vector<int>> res;
        if (nums.size() == 0) return res;
        vector<int> subset;
        dfs(0,subset,res,nums);
        return res;
    }

    void dfs(int index, vector<int>& subset, vector<vector<int>>& res, vector<int>& nums) {
        res.push_back(subset);
        for (int i = index; i < nums.size(); ++i) {
            subset.push_back(nums[i]);
            dfs(i+1,subset,res,nums);
            subset.pop_back();
        }
    }

};

